package com.csun.dsms.service.impl;

import com.csun.dsms.comment.core.support.BaseService;
import com.csun.dsms.mapper.YsStudentMapper;
import com.csun.dsms.mapper.YsTeacherMapper;
import com.csun.dsms.model.domain.YsStudent;
import com.csun.dsms.model.domain.YsTeacher;
import com.csun.dsms.model.dto.ys.YsBindClasses;
import com.csun.dsms.model.dto.ys.YsQueryDto;
import com.csun.dsms.model.dto.ys.YsStudentVo;
import com.csun.dsms.service.YsStudentService;
import com.csun.dsms.service.YsTeacherService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class YsTeacherServiceImpl extends BaseService<YsTeacher> implements YsTeacherService {

    @Resource
    private YsTeacherMapper ysTeacherMapper;

    @Override
    public Integer addTeacher(YsTeacher ysStudent) {
        return ysTeacherMapper.insertSelective(ysStudent);
    }

    @Override
    public Integer deleteTeacherById(Long id) {
        return ysTeacherMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer editTeacher(YsTeacher ysStudent) {
        return ysTeacherMapper.updateByPrimaryKeySelective(ysStudent);
    }

    @Override
    public List<YsTeacher> queryListWithPage(YsQueryDto ysQueryDto) {
        PageHelper.startPage(ysQueryDto.getPageNum(),ysQueryDto.getPageSize());
        return ysTeacherMapper.queryListWithPage(ysQueryDto);
    }


    @Override
    public Integer bindTeacherClass(YsBindClasses ysBindClasses) {
        int result =  ysTeacherMapper.unBindTeacherClass(ysBindClasses);
        ysBindClasses.getClassIdS().forEach(item->{
            ysTeacherMapper.bindTeacherClass(ysBindClasses.getTeacherId(),item);
        });
        return 1;
    }


}
